/*  ------------------------------------------------------------------------  */
/*  Paper        : Does Stakeholder Outrage Determine Executive Pay?          */
/*  Program      : a02-08-ownership.do                                        */
/*  Description  : Institutional ownership analysis                           */
/*  ------------------------------------------------------------------------  */

use "$temp112/outragePanel.dta", clear

/*  ------------------------------------------------------------------------  */
//  Controls

capture drop firm_fe
gen firm_fe = 1


gen f2020 = fyear==2020

rename defer_rpt_as_comp_tot defer_rpt
rename defer_rpt_as_comp_tot_fr defer_rpt_fr

#delimit ;
global compvars
	tdc1 salary varcomp bonus stock_awards_fv option_awards_fv
	noneq_incent othcomp defer_rpt
; #delimit cr


foreach yvar in $compvars {
	winsor2 `yvar', cuts(.5 99.5) suffix(_w)
}

xtset firm_id fyear
gen f2020_salary_cut1 = 2020.fyear#i1.dcut_all
	replace f2020_salary_cut1 = 0 if missing(f2020_salary_cut1)

tab fyear dcut_all if mainsample==1


//  -----------------------------------------
//  own - Non-CEO ownership

summ insideownership if fyear==2020 & mainsample==1, detail
// histogram insideownership if fyear==2020 & mainsample==1, bin(10)
capture drop own_d f2020_own0 f2020_own1
summ insideownership if fyear==2019 & mainsample==1, detail
gen own_d = 1 if (l1.insideownership>=20) & fyear==2020 & mainsample==1
replace own_d = 0 if missing(own_d) & fyear==2020 & mainsample==1

summ tdc1_cps if own_d == 1 & fyear==2020 & mainsample==1
summ tdc1_cps if own_d == 0 & fyear==2020 & mainsample==1

gen f2020_own0 = i1.f2020_salary_cut1#i0.own_d
	replace f2020_own0 = 0 if missing(f2020_own0)
tab fyear f2020_own0 if mainsample==1
gen f2020_own1 = i1.f2020_salary_cut1#i1.own_d
	replace f2020_own1 = 0 if missing(f2020_own1)
tab fyear f2020_own1 if mainsample==1

//  -----------------------------------------
//  HHI - Institutional ownership concentration
summ instoHhi if fyear==2020 & mainsample==1, detail
// histogram tdc1_cps if fyear==2020 & mainsample==1, bin(50)
capture drop hhi_d f2020_hhi0 f2020_hhi1
summ instoHhi if fyear==2019 & mainsample==1, detail
gen hhi_d = 1 if (l1.instoHhi<`r(p50)') & fyear==2020 & mainsample==1
replace hhi_d = 0 if missing(hhi_d) & fyear==2020 & mainsample==1

summ tdc1_cps if hhi_d == 1 & fyear==2020 & mainsample==1
summ tdc1_cps if hhi_d == 0 & fyear==2020 & mainsample==1

gen f2020_hhi0 = i1.f2020_salary_cut1#i0.hhi_d
	replace f2020_hhi0 = 0 if missing(f2020_hhi0)
tab fyear f2020_hhi0 if mainsample==1
gen f2020_hhi1 = i1.f2020_salary_cut1#i1.hhi_d
	replace f2020_hhi1 = 0 if missing(f2020_hhi1)
tab fyear f2020_hhi1 if mainsample==1

//  -----------------------------------------
//  CHU - Churn
summ instoChurn if fyear==2020 & mainsample==1, detail
// histogram instoChurn if fyear==2020 & mainsample==1, bin(50)
capture drop chu_d f2020_chu0 f2020_chu1
summ instoChurn if fyear==2019 & mainsample==1, detail
gen chu_d = 1 if (l1.instoChurn>=`r(p50)') & !missing(l1.instoChurn) & fyear==2020 & mainsample==1
replace chu_d = 0 if missing(chu_d) & fyear==2020 & mainsample==1

summ tdc1_cps if chu_d == 1 & fyear==2020 & mainsample==1
summ tdc1_cps if chu_d == 0 & fyear==2020 & mainsample==1

gen f2020_chu0 = i1.f2020_salary_cut1#i0.chu_d
	replace f2020_chu0 = 0 if missing(f2020_chu0)
tab fyear f2020_chu0 if mainsample==1
gen f2020_chu1 = i1.f2020_salary_cut1#i1.chu_d
	replace f2020_chu1 = 0 if missing(f2020_chu1)
tab fyear f2020_chu1 if mainsample==1

//  -----------------------------------------
//  NIB - f3_NIfilings Institutional Blockholders
summ f3_Ifilings if fyear==2020 & mainsample==1, detail
// histogram tdc1_cps if fyear==2020 & mainsample==1, bin(50)
capture drop nib_d f2020_nib0 f2020_nib1
summ f3_Ifilings if fyear==2019 & mainsample==1, detail
gen nib_d = 1 if (l1.f3_Ifilings>=1) & !missing(l1.f3_Ifilings) & fyear==2020 & mainsample==1
replace nib_d = 0 if missing(nib_d) & fyear==2020 & mainsample==1

summ tdc1_cps if nib_d == 1 & fyear==2020 & mainsample==1
summ tdc1_cps if nib_d == 0 & fyear==2020 & mainsample==1

gen f2020_nib0 = i1.f2020_salary_cut1#i0.nib_d
	replace f2020_nib0 = 0 if missing(f2020_nib0)
tab fyear f2020_nib0 if mainsample==1
gen f2020_nib1 = i1.f2020_salary_cut1#i1.nib_d
	replace f2020_nib1 = 0 if missing(f2020_nib1)
tab fyear f2020_nib1 if mainsample==1

//  -----------------------------------------
//  PRX - Non-management proxy filings
summ proxyFilingsInsto if fyear==2020 & mainsample==1, detail
// histogram tdc1_cps if fyear==2020 & mainsample==1, bin(50)
capture drop prx_d f2020_prx0 f2020_prx1
summ proxyFilingsInsto if fyear==2019 & mainsample==1, detail
tab proxyFilingsInsto if fyear==2019 & mainsample==1
gen prx_d = 0 if (l1.proxyFilingsInsto==0) & fyear==2020 & mainsample==1
replace prx_d = 1 if missing(prx_d) & fyear==2020 & mainsample==1

summ tdc1_cps if prx_d == 1 & fyear==2020 & mainsample==1
summ tdc1_cps if prx_d == 0 & fyear==2020 & mainsample==1

gen f2020_prx0 = i1.f2020_salary_cut1#i0.prx_d
	replace f2020_prx0 = 0 if missing(f2020_prx0)
tab fyear f2020_prx0 if mainsample==1
gen f2020_prx1 = i1.f2020_salary_cut1#i1.prx_d
	replace f2020_prx1 = 0 if missing(f2020_prx1)
tab fyear f2020_prx1 if mainsample==1

//  -----------------------------------------

cls
#delimit ;
global salaryCutMain0415
	ln_mcap btm leverage_mkt tangibility ret_std roa_std xrd_at
	payout_d boardSize boardTenure prc_delta exret_202012
; #delimit cr

capture drop tdc1_wm
	gen tdc1_wm = tdc1_w / 1000

foreach iter in own hhi chu nib prx {

di "----------------------"
di "Processing: `iter'"
di "----------------------"
local xvar ""
if inlist("`iter'","own") local xvar f2020_own0 f2020_own1
if inlist("`iter'","hhi") local xvar f2020_hhi0 f2020_hhi1
if inlist("`iter'","chu") local xvar f2020_chu0 f2020_chu1
if inlist("`iter'","nib") local xvar f2020_nib0 f2020_nib1
if inlist("`iter'","prx") local xvar f2020_prx0 f2020_prx1

foreach yvar in salary bonus stock_awards_fv option_awards_fv noneq_incent othcomp {

local fix f2020 if inrange(fyear,2019,2020) & mainsample==1, a(firm_id) vce(cluster firm_id)

eststo gov_`iter'_`yvar':  reghdfe `yvar'_fr `xvar' $salaryCutMain0415 i.firm_fe `fix'
	if inlist("`iter'","own") lincom _b[f2020_own0] - _b[f2020_own1]
	if inlist("`iter'","hhi") lincom _b[f2020_hhi0] - _b[f2020_hhi1]
	if inlist("`iter'","chu") lincom _b[f2020_chu0] - _b[f2020_chu1]
	if inlist("`iter'","nib") lincom _b[f2020_nib0] - _b[f2020_nib1]
	if inlist("`iter'","prx") lincom _b[f2020_prx0] - _b[f2020_prx1]
		qui estadd scalar comb_c = r(estimate)
		qui estadd scalar comb_t = r(t)

//  Dollar value regressions
capture drop `yvar'_wm
	gen `yvar'_wm = `yvar'_w / 1000
eststo govw_`iter'_`yvar': qui reghdfe `yvar'_wm `xvar' tdc1_wm $salaryCutMain0415 i.firm_fe `fix'
	if inlist("`iter'","own") lincom _b[f2020_own0] - _b[f2020_own1]
	if inlist("`iter'","hhi") lincom _b[f2020_hhi0] - _b[f2020_hhi1]
	if inlist("`iter'","chu") lincom _b[f2020_chu0] - _b[f2020_chu1]
	if inlist("`iter'","nib") lincom _b[f2020_nib0] - _b[f2020_nib1]
	if inlist("`iter'","prx") lincom _b[f2020_prx0] - _b[f2020_prx1]
		qui estadd scalar comb_c = r(estimate)
		qui estadd scalar comb_t = r(t)

}
}

#delimit ;
global complayout0420
	, b(%8.3f) t(%8.3f) star(* 0.10 ** 0.05 *** 0.01)
	nonotes stats(comb_c comb_t r2_a N_full,
				layout(@ (@) @ @)
				fmt(%8.3f %8.3f %8.3f %8.0fc)
				labels("Difference" " " "Adjusted R2" "Observations"))
	indicate(	"Controls = $salaryCutMain0415 *firm_fe _cons")
; #delimit cr

/*  ------------------------------------------------------------------------  */
//  Show results

// Firm ownership structure and CEO compensation outcomes
esttab gov_own_* $complayout0420 nogap

// Ownership concentration and CEO compensation outcomes
esttab gov_hhi_* $complayout0420 nogap

// Institutional ownership churn and CEO compensation outcomes
esttab gov_chu_* $complayout0420 nogap

// Newly emerged institutional investors and CEO compensation outcomes
esttab gov_nib_* $complayout0420 nogap

// Non-management proxy filings and CEO compensation outcomes
esttab gov_prx_* $complayout0420 nogap

/*  -|----------------------------------------------------------------------  */
/*  ||  ---    Program end: a02-08-ownership.do                               */
/*  -|  ---    Attila Balogh    --------------------------------------------  */